class Solution {
    public int reverse(int x) {
        //整数反转
        if(x>0){
            long k=0,y=0;
            while(x>0){
                k=x%10;
                y=y*10+k;
                x=x/10;
            }
           
            return (int)y==y? (int)y:0;
        }
        //负数先变成正数反转，
        if(x<0){
            x=-x;
             long  k=0,y=0;
            while(x>0){
                k=x%10;
                y=y*10+k;
                x=x/10;
            }
            return (int)-y==-y? (int)-y:0;
        }
        if(x==0) return 0;
        return 0;
    }
}